/***************************************************************************
   Filename:    Ball.h
   Author:      Josh Partridge
   Description: The Ball class acts as the ball in Breakout
****************************************************************************/
#ifndef BALL_H_INCLUDED
#define BALL_H_INCLUDED

#include <cmath>
#include <vector>
#include "Brush.h"
#include "Brick.h"

const double PI = 3.14159;
//increment for ball's angle
const double angleInc = 12.25;

class Ball
{
    private:
        //coordinates
        double x, y;
        //ball's orientation in DEGREES
        //0 degrees is right (unit circle)
        double theta;
        double magnitude;
        ink color;
        unsigned int* score;

        /************************************************************************************
         Name:               xCollide
         Description:        used by move() to detect collision with anything in the x-axis
         Input:
                         dx: double representing attempted change in x position
                  paddlePos: an integer value representing the maximum value
                     bricks: address of the vector holding the level's bricks
                      brush: address of the game's brush object
                             (for updating brick's appearance)
         Output:
                     return: bool value testing whether anything collided
                     bricks: address of the vector holding the level's bricks
                      brush: address of the game's brush object
         *************************************************************************************/
        bool xCollide(double dx, int paddlePos, vector<Brick>& bricks, Brush& brush);

         /************************************************************************************
         Name:               yCollide
         Description:        used by move() to detect collision with anything in the y-axis
         Input:
                         dy: double representing attempted change in y position
                  paddlePos: an integer value representing the maximum value
                  paddleVel: paddle's velocity, for affecting ball trajectory
                     bricks: address of the vector holding the level's bricks
                      brush: address of the game's brush object
                             (for updating brick's appearance)
         Output:
                     return: bool value testing whether anything collided
                     bricks: address of the vector holding the level's bricks
                      brush: address of the game's brush object
        *************************************************************************************/
        bool yCollide(double dy, int paddlePos, int paddleVel, vector<Brick>& bricks, Brush& brush);

    public:

        /************************************************************************************
         Name:               Ball - constructors
         Description:        initialize various attributes of Ball
         Input:
                      x_pos: double representing x position of ball
                      y_pos: double representing x position of ball
                          c: ink representing color of the ball
                          s: pointer to game's score variable
        *************************************************************************************/
        Ball();
        Ball(unsigned int* s);
        Ball(double x_pos, double y_pos, unsigned int* s);
        Ball(ink c, unsigned int* s);
        Ball(double x_pos, double y_pos, ink c, unsigned int* s);

        /************************************************************************************
         Name:               setTheta
         Description:        setter for theta attribute (double)
         Input:
                          t: double representing new angle
        *************************************************************************************/
        void setTheta(double t);

         /************************************************************************************
         Name:               getTheta
         Description:        getter for theta attribute (double)
         Output:
                     return: double representing ball's theta attribute
         *************************************************************************************/
        double getTheta();

        /************************************************************************************
             Name:           setMagnitue
             Description:    setter for magnitude attribute
             Input:
                        mag: new magnitude (double)
        *************************************************************************************/
        void setMagnitude(double mag);

        /************************************************************************************
         Name:               setColor
         Description:        setter for color attribute (ink)
         Input:
                          c: ink representing new color
        *************************************************************************************/
        void setColor(ink c);

        /************************************************************************************
         Name:               teleport
         Description:        moves ball without collision testing
         Input:
                      x_pos: double representing new x coordinate
                      y_pos: double representing new y coordinate
        *************************************************************************************/
        void teleport(double x_pos, double y_pos);

        /************************************************************************************
         Name:               move
         Description:        determines ball movement both before and after release from paddle
         Input:
                     bricks: address of the vector holding the level's bricks
                  paddlePos: an integer value representing the maximum value
                  paddleVel: paddle's velocity, for affecting ball trajectory
                      brush: address of the game's brush object
                             (for updating brick's appearance)
         Output:
                     return: bool value testing whether ball crossed the screen's lower bound
                     bricks: address of the vector holding the level's bricks
                      brush: address of the game's brush object
        *************************************************************************************/
        bool move(vector<Brick>& bricks, int paddlePos, int paddleVel, Brush& brush);

        /************************************************************************************
         Name:               draw
         Description:        method for displaying itself to the screen
         Input:
                      brush: address of the game's brush object
                             (for drawing in new position)
        *************************************************************************************/
        void draw(Brush& brush);

        /************************************************************************************
         Name:               erase
         Description:        method for erasing old position
         Input:
                      brush: address of the game's brush object
                             (for drawing in new position)
        *************************************************************************************/
        void erase(Brush& brush);
};

#endif // BALL_H_INCLUDED
